package org.controller.test.config;

import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {

	@Bean
	public ConnectionFactory connectionFactory() {

		CachingConnectionFactory factory = new CachingConnectionFactory();
		
		factory.setUri("amqp://guest:guest@localhost:5672");
		
		return factory;
	}

	@Bean
	public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {

		RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);

		return rabbitAdmin;
	}
	
	
	@Bean
	public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory){
		
		RabbitTemplate rabbitTemplate=new RabbitTemplate(connectionFactory);
		
		
		
		return rabbitTemplate;
	}

}
